<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>综合案例</title>

    <style>
        .active{
            color: red;
        }
    </style>

</head>
<body>
    <script src='/js/vue.js'></script>
    <div id='app'>
        <!-- ul 无序标签 -->
        <!-- 鼠标点击变红 -->
        <!-- 用下标index获取 -->
        <ul>
            <li :class="{active:index === currentIndex}" v-for="(bool,index) in books" @click="btnClick(index)">{{book}}</li>
        </ul>


        <p>{{msg}}</p>
    </div>
<br>
    <script>
        let app = new Vue({
            el:'#app',
            data:{
                msg:'hello word',
                books:['三国演义','西游记','红楼梦','水浒传'],
                currentIndex:''
            },
            methods:{
                btnClick(index){
                    this.currentIndex = index
                    console.log(index)
                }
            }
        })
    </script>
</body>
</html>